package com.ruoyi.web.utils.v2.property;

import cn.hutool.core.lang.Opt;
import com.ruoyi.web.domain.warning.FactorInfo;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Date;
import java.util.Map;
import java.util.Optional;

@Data
public class V2DeviceProperty implements V2ThingProperty {

    private String id;

    @Schema(description = "设备ID")
    private String deviceId;

    @Schema(description = "属性ID")
    private String property;

    @Schema(description = "属性名")
    private String propertyName;

    @Schema(description = "类型")
    private String type;

    @Schema(description = "单位")
    private String unit;

    @Schema(description = "tag")
    private String tag;
    @Schema(description = "group")
    private String propertyGroup;
    @Hidden
    private Object numberValue;
    @Hidden
    private Object objectValue;
    @Hidden
    private Date timeValue;
    @Hidden
    private String stringValue;
    @Hidden
    private V2GeoPoint geoValue;

    @Schema(description = "属性值")
    private Object value;

    @Schema(description = "格式化值")
    private Object formatValue;

    private long createTime;

    /**
     * 数据时间
     */
    private long timestamp;

    /**
     * "格式化后的时间,在聚合查询时此字段有值
     */
    private String formatTime;

    /**
     * 设备状态值,如果是查询的数据库,此字段可能为{@link null}
     * 状态值
     */
    private String state;

    private FactorInfo factorInfo;

    private Map<String, Object> expands;

    public String conExpandsStr(String key){
        return expands.get(key) == null ? null : expands.get(key) + "";
    }

}

